package com.pb.web.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class UserAction01 extends ActionSupport {

	private static final long serialVersionUID = -4912422520770709300L;

	private String username;

	private String password;
	private Map<String, Object> request;
	private Map<String, Object> session;
	private Map<String, Object> application;

	@SuppressWarnings("unchecked")
	public String login() {
		// 获取对象
		ActionContext ac = ActionContext.getContext();
		request = (Map<String, Object>) ac.get("request");
		session = ac.getSession();
		application = ac.getApplication();
		// 保存数据
		request.put("loginAddress", "您本次登陆地点是：北京");
		session.put("username", username+password);
		application.put("online", "当前在线人数：XXX");
		// 获取数据
		System.out.println(request.get("loginAddress"));
		System.out.println(session.get("username"));
		System.out.println(application.get("online"));
		return SUCCESS;
	}

	/**
	 * 获取 username
	 * 
	 * @return username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * 设置 username
	 * 
	 * @param username
	 *            username
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * 获取 password
	 * 
	 * @return password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * 设置 password
	 * 
	 * @param password
	 *            password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

}
